<script>
    var d = '<?= count($details->availability) > 0 ? json_encode($details->availability) : 0; ?>';
    var preview = '<?= isset($_GET['preview']) ? 1 : 0; ?>';
</script>

<?

//$this->firephp->log($details->availability);
/*
* Checkin, Checkout
*/
$check_in = date('d.m.Y', strtotime("+1 day"));

if (isset($_GET['check_in']))
    $check_in = $_GET['check_in'];

$check_out = date('d.m.Y', strtotime("+2 day"));

if (isset($_GET['check_out']))
    $check_out = $_GET['check_out'];

/*
* Number persons
*/
$sel_text = 'selected = "selected"';

if (isset($_GET['nr_adults'])) {
    $selected = $_GET['nr_adults'];
    $cnt = (isset($_GET['acc_type']) && $_GET['acc_type'] == 'hotel') ? 5 : 12;
} else if (isset($_GET['acc_type']) && $_GET['acc_type'] == 'hotel') {
    $selected = 2;
    $cnt = 5;
} else {
    $selected = 2;
    $cnt = 5;
}

/*
 * Service and prices
 */
$service_name = $details->cur_room->service_name;
$service_total = !isset($_GET['preview']) ? $details->cur_room->selling_total : '0';
?>

<div class="x_prices fix">



    <form id="pricesForm" method="GET" action="<?= lang_url('checkout'); ?>">

        <input type="hidden" name="hotel_id" id="hotel_id" value="<?= $_GET['hotel_id'] ?>">
        <input type="hidden" name="room_id" id="room_id" value="<?= $_GET['room_id'] ?>">

        <div class="clearfix two_col small_grad">

            <div class="section">

                <h2><?= lang('define_date'); ?>:</h2>


                <div class="clearfix">
                    <div class="form_col">
                        <label for="check_in"><?= lang('define_arrival'); ?></label>

                        <div class="input clearfix">
                            <input type="text" value="<?= $check_in ?>" name="check_in" id="check_in"
                                   class="checkinout"/>
                        </div>
                    </div>
                    <div class="form_col">
                        <label for="check_out"><?= lang('define_departure'); ?></label>

                        <div class="input clearfix">
                            <input type="text" value="<?= $check_out ?>" name="check_out" id="check_out"
                                   class="checkinout"/>
                        </div>
                    </div>
                </div>

            </div>

            <div class="section">

                <h2><?= lang('no_persons'); ?>:</h2>

                <div class="clearfix">
                    <div class="form_col">

                        <label for="nr_adults"><?= lang('dtl.adults') ?> (18+)</label>

                        <div class="input clearfix">
                            <select name="nr_adults" id="nr_adults">

                                <?
                                $selected = !isset($_GET['preview']) ? $_GET['nr_adults'] : $selected;
                                $sel_text = 'selected = "selected"';
                                for ($index = 1; $index <= $cnt; $index++):
                                    ?>

                                    <option
                                        value="<?= $index ?>" <? if ($selected == $index) echo $sel_text; ?>><?= $index ?></option>

                                <? endfor; ?>

                            </select>
                        </div>
                    </div>
                    <div class="form_col">
                        <label><?= lang('dtl.children') ?> (2-12):</label>

                        <div class="input clearfix">
                            <select name="nr_childrens" id="nr_childrens">
                                <? for ($index = 0; $index <= 5; $index++): ?>
                                    <option value="<?= $index ?>"><?= $index ?></option>
                                <? endfor; ?>
                            </select>
                        </div>

                    </div>
                    <div class="form_col">
                        <label><?= lang('dtl.babies'); ?> (0-2):</label>

                        <div class="input clearfix">
                            <select name="nr_babies" id="nr_babies">
                                <? for ($index = 0; $index <= 5; $index++): ?>
                                    <option value="<?= $index ?>"><?= $index ?></option>
                                <? endfor; ?>
                            </select>
                        </div>

                    </div>
                </div>

            </div>

        </div>

        <div class="section ">

<!--            <h2>Check availability:</h2>-->

            <div class="form_prices clatopborder clearfix">


                <div class="inner_prices" id="claendar_css">

                    <div class="too_many"></div>

                    <div class="cal_border">

                        <div id="calendar" class="clearfix"></div>

                    </div>

                    <div class="cal_legend">
                        <ul>
                            <li><span class="f">15</span> <?= lang('available'); ?></li>
                            <li><span class="t">15</span> <?= lang('occupied'); ?></li>
                            <li><span class="s">15</span> <?= lang('selected'); ?></li>

                        </ul>

                        <div id="instructions"><?= lang('instructions'); ?></div>
                    </div>

                </div>
            </div>

        </div>

        <div class="section">

            <h2><?= lang('calculation'); ?>:</h2>

            <div id="calculation" class="form_prices clearfix calculation">


                <ul>
                    <li><?= lang('dtl.num_of_persons'); ?>:
                    <span class="service_persons">
                        <?= lang('dtl.adults'); ?>: <?= !isset($_GET['preview']) ? $_GET['nr_adults'] : $selected ?>,
                        <?= lang('dtl.children'); ?>: 0,
                        <?= lang('dtl.babies'); ?>: 0
                         </span>
                    </li>
                    <li><?= lang('dtl.period'); ?>:
                    <span class="service_periods"><?= !isset($_GET['preview']) ? $_GET['check_in'] : '' ?>
                        - <?= !isset($_GET['preview']) ? $_GET['check_out'] : '' ?></span></li>
                    <li><?= $service_name ?>: <span class="service_total"><?= $service_total ?> </span> €</li>
                    <li class="price_total"><?= lang('total'); ?>: <span
                            class="service_total"><?= $service_total ?> </span> €
                    </li>
                </ul>

                <div class="tax"><?= lang('dtl.tax_included'); ?></div>

            </div>

        </div>

        <div class="section submit" >
            <input type="submit" class="button green" value="<?=lang('res.book_now')?>">
        </div>

    </form>

</div>